package com.demo.spring.tools;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;

@Component
public class ReservationTool {
	
	@Autowired
	private ReservationService reservationService;
	
	@Tool("添加志愿指导服务预约")
	public void addReservation(
		@P("考生姓名") String name,
		@P("考生性别") String gender,
		@P("考生手机号") String phone,
		@P("预约沟通时间，格式为：yyyy-MM-dd'T'HH:mm") String communicationTime,
		@P("考生所在省份") String province,
		@P("考生预估分数")Integer estimatedScore) {
		reservationService.insert(new Reservation(null, name, gender, phone, LocalDateTime.parse(communicationTime), province, estimatedScore));
	}
	
	@Tool("根据考生手机号査询考生预约详情")
	public Reservation findReservation(@P("考生手机号") String phone){
		return reservationService.findByPhone(phone);
	}

}